home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!ittpub!ittpub!nntp
- Newsgroups: comp.lang.c++
- Subject: Re: Why don't you use garbage collection
- Message-ID: <1996Apr16.110526.1846@ittpub>
- From: wil@ittpub.nl (Wil Evers)
- Date: 16 Apr 96 11:05:26 WET
- References: <AD94A731966836BF@dialup97-6-14.swipnet.se>
- Distribution: world
- Nntp-Posting-Host: lintilla
-
- In article <AD94A731966836BF@dialup97-6-14.swipnet.se> lars.farm@nts.mh.se
- (Lars Farm) writes:
- > In article <AUSTERN.96Apr12095652@isolde.mti.sgi.com>,
- > austern@isolde.mti.sgi.com (Matt Austern) wrote:
- >
- > >In C++ we're used to the idea that heap-allocated and stack-allocated
- > >objects have different rules. It's not so radical to introduce
- > >garbage-collected objects as a third category.
- >
- > My sentiments exactly.
-
- OK, let's get serious about this:
-
- 1. Don't we think C++ is complex enough as it is? In my experience, the
- main obstacle to get people to use C++ is its steep learning curve, and
- adding yet a third category of objects wouldn't make things any easier.
-
- 2. Will the destructors of garbage collected objects be called?
-
- 3. If the answer to (2) is NO: how do we make sure we don't get resource
- leaks for non-memory resources?
- To elaborate: IMHO, the type of resources used by a particular class is an
- implementation detail its users should not have to know or worry about,
- and implementers should be able to change that without affecting the
- users.
- But even if we drop this constraint, derived classes should be able to use
- additional resource types without changing the `garbage collectability' of
- objects accessed through the base class interface.
-
- 4. If the answer to (2) is YES: when will these destructors be called?
- What can we assume about the state of the program when the destructor
- runs? How do we guarantee a shortage of non-memory resources is detected
- by the garbage collector before we get to the point where the program
- can't continue?
-
- - Wil
-